-
Notifications
You must be signed in to change notification settings - Fork 155
feat(event-handler): add Amazon Bedrock Agents Functions Resolver #3957
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
} | ||
|
||
const parameterObject: Record<string, string> = Object.fromEntries( | ||
parameters.map((param) => [param.name, param.value]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One of the consequences of not having vaildation using the Zod parser is that all these arguments will be strings because they are coming from the parameters
object in the lambda event. This means that users will need to ensure they cast the arguments to correct type. Another option is to use the type
we get in the parameters objects and cast based on that in lieu of not having Zod.
}; | ||
|
||
// biome-ignore lint/suspicious/noExplicitAny: this is a generic type that is intentionally open | ||
type Tool<TParams = Record<string, any>> = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As mentiioned, technically this function with only take strings because we are not using Zod to parse but in the future we will need the type to be open to accepting any arguments.
Edit: this type is too lose even if we had parsing. According to the docs the only supported types are the following:
string | number | integer | boolean | array
This comment was marked as outdated.
This comment was marked as outdated.
// biome-ignore lint/suspicious/noExplicitAny: this is a generic type that is intentionally open | ||
type Tool<TParams = Record<string, any>> = { | ||
// biome-ignore lint/suspicious/noConfusingVoidType: we need to support async functions that don't have an explicit return value | ||
function: (params: TParams) => Promise<JSONValue | void>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We use the type system here to only allow values to be returned that can be serialised to JSON.
@@ -8,3 +8,22 @@ export type { | |||
RouteOptions, | |||
RouterOptions, | |||
} from './appsync-events.js'; | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure what the difference for exporting types here and the packages/event-handler/src/types/bedrock-agent-function.ts
file is here so I've exported everything.
aa4e007
to
59db37b
Compare
public tool( | ||
fnOrConfig: ToolFunction | Configuration, | ||
config?: Configuration | ||
): MethodDecorator | void { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Take particular notice of this part, I've never worked with decorators before so any feedback here is particularly welcome.
59db37b
to
883fbfd
Compare
883fbfd
to
6212f21
Compare
|
Summary
Adds a new resolver type to the
event-handler
package to handle lambda functions invoked by Amazon Bedrock agents.Changes
tool
- takes an async function and a configuration object withname
anddescription
fields and registers the toolresolve
- accepts the lambda event and context objects from the handler and routes the request to the correct tool and returns an appropriately formatted response. Can also be used as a method or a decorator.Issue number: #3710
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
Disclaimer: We value your time and bandwidth. As such, any pull requests created on non-triaged issues might not be successful.